public class School {
    private int teacherCount;     // 教师人数
    private double totalSalary;   // 总工资

    TeacherManager teacherManager; // 教师管理内部类

    School() {
        teacherCount = 0;
        totalSalary = 0;
        teacherManager = new TeacherManager();
    }

    // 查看当前学校数据
    void displaySchoolData() {
        System.out.println("\n===== 学校数据统计 =====");
        System.out.println("教师人数：" + teacherCount);
        System.out.println("教师工资总额：" + totalSalary);
    }

    class TeacherManager {
        final double MIN_SALARY = 5000;  // 最低工资
        final double MAX_SALARY = 30000; // 最高工资

        void addTeacher(double salary) {
            if (salary >= MIN_SALARY && salary <= MAX_SALARY) {
                teacherCount++;
                totalSalary += salary;
                System.out.println(" 新增一位教师，工资：" + salary);
            } else {
                System.out.println("[ERROR] 教师工资必须在" + MIN_SALARY + "~" + MAX_SALARY + "之间！");
            }
        }

        void removeTeacher(double salary) {
                teacherCount--;
                totalSalary -= salary;
                System.out.println(" 一位教师离职，工资：" + salary);
        }
    }
        public static void main(String[] args) {
        School school = new School();

        school.teacherManager.addTeacher(8000);
        school.teacherManager.addTeacher(15000);
        school.teacherManager.addTeacher(25000);
        school.teacherManager.addTeacher(3000);  // 会报错（工资太低）// 
        school.displaySchoolData();
        school.teacherManager.removeTeacher(8000);
        school.displaySchoolData();
    }
}

